package algorithm.gothrough;


import algorithm.BinTreeNode;

public class BinaryTreePreorderTraversal {
// 创建一个二叉树
    public static BinTreeNode createBinTree(){
        BinTreeNode R3 = new BinTreeNode('F',0,null,null);
        BinTreeNode L2 = new BinTreeNode('D', 0, null, null);
        BinTreeNode R2 = new BinTreeNode('E', 0, null, R3);
        BinTreeNode L1 = new BinTreeNode('B', 0, L2, R2);
        BinTreeNode R1 = new BinTreeNode('C', 0, null, null);
        BinTreeNode T = new BinTreeNode('A', 0, L1, R1);
        return T;
    }
    //使用递归实现
    public static void preOrder(BinTreeNode top){
        if(top != null){
            System.out.println(top.data);
            preOrder(top.leftnode);
            preOrder(top.rightnode);
        }
    }

}
